package com.hexinfo.dmpro.data.transfer.common.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @Package: com.hexinfo.dmpro.data.transfer.common.model
 * @ClassName SourceRuleTableView
 * @Description: 数据源规则表视图, 当没有源分区字段时，日期分区字段会在partKey1和partValue1中
 * @Author: wz.li
 * @Date 2023/11/6 19:08
 * @Version v2.0.2
 **/
@Data
@ApiModel(value = "数据源规则表视图")
@Accessors(chain = true)
public class SourceRuleTableView {

    @ApiModelProperty(value = "库名")
    private String tblDatabaseName;

    @ApiModelProperty(value = "表名")
    private String tblName;

    @ApiModelProperty(value = "分区字段")
    @TableField(exist = false)
    private List<String> partitionField;

    @ApiModelProperty(value = "时间分区字段名")
    @TableField(exist = false)
    private String datePartitionName;

    @ApiModelProperty(value = "时间分区字段格式")
    @TableField(exist = false)
    private String datePartitionFormat;

    @ApiModelProperty(value = "HDFS路径到表级")
    private String location;

    @ApiModelProperty(value = "HDFS分区路径")
    private String partName;

    @ApiModelProperty(value = "源名称")
    private String sourceName;

    @ApiModelProperty(value = "分区字段名称1(源或日期分区)")
    private String partKey1;

    @ApiModelProperty(value = "分区字段值1(源或日期分区)")
    private String partValue1;

    @ApiModelProperty(value = "分区字段名称2(日期分区)")
    private String partKey2;

    @ApiModelProperty(value = "分区字段值2(日期分区)")
    private String partValue2;

    @ApiModelProperty(value = "日期分区字段位置")
    private String dateIndex;

    /**
     * 按源导出源值集合
     */
    @TableField(exist = false)
    private List<String> sourceValues;

    /**
     * 自定义查询条件
     */
    @TableField(exist = false)
    private String customWhere;

    public String getDbNameAndTableName() {
        return tblDatabaseName + "." + tblName;
    }

    public String getDbNameAndTxtTableName() {
        return tblDatabaseName + ".txt_" + tblName;
    }
}
